#  Copyright (c) 2007 Microsoft Corporation. All rights reserved.
require 'logger'
$KCODE = 'UTF8'

module VMXT2TFS
  #This module defines the version numbers for the library
  module Version
    MAJOR=1
    MINOR=0
    TINY=1
    STRING=[ MAJOR, MINOR, TINY ].join( "." )
    #used to add a build number to the TFS template name
    BUILD=[ MAJOR, MINOR, TINY ].join( "" )  	
  end
  #filename for the log file
  VMXT2TFS_LOG='vmxt2tfs-generator.log'
  MERGE_LOG='vmxt2tfs-merge.log'
  #Default name for the output directory
  OUTPUT='vmxttfs-out'
  #default filename for the CSV version of the project plan
  PLAN="plan.csv"
  #default filename for the XML version of the project plan
  VMP_PLAN="plan.vmp"

  #Sets up the logger with appropriate levels and format
  def self.setup_logger no_file=true, logfile=VMXT2TFS_LOG
    if no_file
      logger=Logger.new(STDOUT)
    else
      logger=Logger.new(logfile)
    end
    logger.level=Logger::INFO
    logger.level=Logger::DEBUG if $DEBUG
    logger.formatter=LoggerFormatter.new
    logger.debug("Logger initialized")
    return logger
  end
  #Formats the log output a bit compacter than normal
  class LoggerFormatter<Logger::Formatter
    Format="[%s] %5s: %s\n"
    def initialize
      @datetime_format="%Y%m%d %H:%M:%S"
    end

    def call severity, time, progname, msg
      Format % [format_datetime(time), severity,msg2str(msg)]
    end
  end
end